/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chalmers.se.tda367.observer;

import edu.chalmers.se.tda367.gui.view.LoggedInTeacherView;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;

/**
 *
 * @author pierrereimertz
 */
public class GlobalObserverList {

    private static final GlobalObserverList INSTANCE = new GlobalObserverList();
    private PropertyChangeSupport observers = new PropertyChangeSupport(this);
    private String oldName;
    private Object checkOldValue;
    private Object checkNewValue;

    private GlobalObserverList() {
    }

    public void firePropertyChange(String name, Object oldValue, Object newValue) {
        // if (!(name.equals(oldName) && checkOldValue.equals(oldValue) && checkNewValue.equals(newValue))) {
        observers.firePropertyChange(name, oldValue, newValue);
        // oldName = name;
        //checkOldValue = oldValue;
        //checkNewValue = newValue;
        //}
        //allt som lyssnar på ObserverHandler och använder sig av 
        //observers.firePropertyChange(a,b,c) kommer skicka ut ocg få goa saker

    }

    public void addObserver(PropertyChangeListener observer) {
        observers.addPropertyChangeListener(observer);

    }

    public static GlobalObserverList getInstance() {
        return INSTANCE;
    }
}
